package bb.lanxing.common.messager;

import android.os.Bundle;
import android.os.Message;

public class MessageSender {
    private MessageHandler messageHandler = new MessageHandler();

    public boolean registerListener(EventMessageListener eventMessageListener) {
        return this.messageHandler.registerListener(eventMessageListener);
    }

    public boolean unregisterListener(EventMessageListener eventMessageListener) {
        return this.messageHandler.unregisterListener(eventMessageListener);
    }

    public void sendMessage(int what) {
        sendMessageDelayed(what, 0, 0, null, null, 0L);
    }

    public void sendMessage(int what, Bundle bundle) {
        sendMessageDelayed(what, 0, 0, null, bundle, 0L);
    }

    public void sendMessage(int what, Object obj) {
        sendMessageDelayed(what, 0, 0, obj, null, 0L);
    }

    public void sendMessage(int what, int arg1, int arg2) {
        sendMessageDelayed(what, arg1, arg2, null, null, 0L);
    }

    public void sendMessage(int what, int arg1, int arg2, Bundle bundle) {
        sendMessageDelayed(what, arg1, arg2, null, bundle, 0L);
    }

    public void sendMessage(int what, int arg1, int arg2, Object obj) {
        sendMessageDelayed(what, arg1, arg2, obj, null, 0L);
    }

    public void sendMessage(int what, int arg1, int arg2, Object obj, Bundle bundle) {
        sendMessageDelayed(what, arg1, arg2, obj, bundle, 0L);
    }

    public void sendMessageDelayed(int what, int arg1, int arg2, Object obj, Bundle bundle, long delayMillis) {
        Message obtainMessage = this.messageHandler.obtainMessage(what, arg1, arg2, obj);
        obtainMessage.setData(bundle);
        MessageHandler messageHandler = this.messageHandler;
        if (delayMillis < 0) {
            delayMillis = 0;
        }
        messageHandler.sendMessageDelayed(obtainMessage, delayMillis);
    }

    public void cancelMessage(int what) {
        this.messageHandler.removeMessages(what);
    }

    public void cancelMessage(int what, Object obj) {
        this.messageHandler.removeMessages(what, obj);
    }
}